/**
 * Project Name:JavaBaseReview
 * Package Name:com.xuwei.base.enumeration
 * author:David
 * Date:2016年6月7日上午8:53:49
 * Copyright (c) 2016, xw123box@126.com All Rights Reserved.
 *
 */
package com.xuwei.base.enumeration;

/**
 * 普通类模拟实现枚举功能2
 * @author David
 * @since 2016年6月7日 上午8:53:49
 * @version 
 * @since JDK 1.6
 */
public class Demo2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Student2 s = new Student2();
		s.setName("David");
		s.setGrade(Grade.B);
		System.out.println(s.getGrade().getValue());
		System.out.println(s.getGrade().toLocaleString());
	}

}

class Student2{
	private String name;
	private Grade grade;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Grade getGrade() {
		return grade;
	}
	public void setGrade(Grade grade) {
		this.grade = grade;
	}
}

abstract class Grade{
	private String value;
	private Grade(String value){
		this.value = value;
	}
	
	public String getValue() {
		return value;
	}

	public abstract String toLocaleString();
	
	public final static Grade A = new Grade("100~90"){
		@Override
		public String toLocaleString(){
			return "优秀";
		}
	};
	public final static Grade B  = new Grade("89~80"){
		@Override
		public String toLocaleString(){
			return "良好";
		}
	};
	public final static Grade C = new Grade("79~70"){
		@Override
		public String toLocaleString(){
			return "一般";
		}
	};
	public final static Grade D = new Grade("69~60"){
		@Override
		public String toLocaleString(){
			return "及格";
		}
	};
	public final static Grade E = new Grade("59~0"){
		@Override
		public String toLocaleString(){
			return "不及格";
		}
	};
}



